<template>
    <div>
        <!-- 面包屑导航 -->
        <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item><a href="/">订单管理</a></el-breadcrumb-item>
            <el-breadcrumb-item>订单列表</el-breadcrumb-item>
        </el-breadcrumb>
        <!-- 面板区域 -->
        <el-card class="box-card" style="margin-top:20px">
            <!-- 输入框 -->
            <el-row>
                <el-col :span="12">
                    <div class="grid-content bg-purple">
                        <el-input placeholder="请输入内容" class="input-with-select" v-model="queryinfo.query" clearable @clear='getOrderList'>
                            <el-button slot="append" icon="el-icon-search" @click="getOrderList"></el-button>
                        </el-input>
                    </div>
                </el-col>
                <el-col :span="12">
                    <div class="grid-content bg-purple-light" style="margin-left:20px">
                        <el-button type="primary" @click="adddialogVisible = true">添加订单</el-button>
                    </div>
                </el-col>
            </el-row>
            <!-- 表格 -->
            <div style="margin-top:20px">
                <template>
                    <el-table :data="orderList" border="" style="width: 100%">
                        <el-table-column type='index'></el-table-column>
                        <el-table-column prop="order_number" label="订单编号" width="266">
                        </el-table-column>
                        <el-table-column prop="order_price" label="订单价格" width="200">
                        </el-table-column>
                        <el-table-column prop="pay_status" label="是否付款" width="200">
                            <template slot-scope="scope">
                                <el-tag type="success" v-if='scope.row.pay_status == 1'>已付款</el-tag>
                                <el-tag type="danger" v-else>未付款</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column prop="is_send" label="是否发货" width="200">
                        </el-table-column>
                        <el-table-column prop="create_time" label="下单时间" width="300">
                            <template slot-scope="scope">
                                {{scope.row.create_time | dataFormat}}
                            </template>
                        </el-table-column>
                        <el-table-column label="操作" width="210">
                            <template slot-scope='scope'>
                                <el-tooltip content="编辑" placement="top">
                                    <el-button type="primary" icon="el-icon-edit" size="small" ></el-button>
                                </el-tooltip>
                                <el-tooltip content="地址" placement="top">
                                    <el-button type="success" icon="el-icon-location" size="small" @click="showProgress"></el-button>
                                </el-tooltip>
                            </template>
                        </el-table-column>
                    </el-table>
                </template>
            </div>
            <!-- 分页 -->
            <div class="block" style="margin-top:20px">
                <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="queryinfo.pagenum"
                :page-sizes="[1, 2, 5, 10]"
                :page-size="queryinfo.pagesize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
                </el-pagination>
            </div>
        </el-card>
        <!-- 物流弹出框 -->
        <el-dialog
        title="物流信息"
        :visible.sync="prodialogVisible"
        width="30%">
        <el-timeline>
            <el-timeline-item
            v-for="(activity, index) in progressInfo"
            :key="index"
            :timestamp="activity.time">
                {{activity.context}}
            </el-timeline-item>
        </el-timeline>
        <span slot="footer" class="dialog-footer">
            <el-button @click="prodialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="prodialogVisible = false">确 定</el-button>
        </span>
        </el-dialog>
    </div>
</template>

<script>
export default {
    data() {
        return {
            queryinfo:{query:'',pagenum:1,pagesize:5},
            adddialogVisible:false,
            orderList:[],
            total:0,
            progressInfo:[],
            prodialogVisible:false
        }
    },
    created() {
        this.getOrderList()
    },
    methods:{
        async getOrderList(){
            let {data : res} = await this.$http.get('orders',{
                params:this.queryinfo
            })
            if(res.meta.status != 200) return this.$message.error(res.meta.msg)
            this.orderList = res.data.goods
            this.total = res.data.total
            this.queryinfo.pagenum = res.data.pagenum
        },
        handleSizeChange(newPagesize) {
            this.queryinfo.pagesize = newPagesize
            this.getOrderList()
        },
        handleCurrentChange(newPagenum) {
            this.queryinfo.pagenum = newPagenum
            this.getOrderList()
        },
        async showProgress () {
            let {data : res} = await this.$http.get('/kuaidi/804909574412544580')
            if(res.meta.status != 200) return this.$message.error(ree.meta.msg)
            this.progressInfo = res.data
            this.prodialogVisible = true
            // console.log(this.progressInfo)
        }
    }
}
</script>

<style lang="less" scoped>
@import '../plugins/timeline/timeline.css';
@import '../plugins/timeline-item/timeline-item.css';
</style>
